package com.isdepci.project.gasEmission.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.gasEmission.domain.ProductApportionment;
import com.isdepci.project.gasEmission.service.IProductApportionmentService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 产品分摊Controller
 *
 * @author isdepci
 * @date 2023-09-01
 */
@RestController
@RequestMapping("/productApportionment/productApportionment")
public class ProductApportionmentController extends BaseController
{
    @Autowired
    private IProductApportionmentService productApportionmentService;

    /**
     * 查询产品分摊列表
     */
    @PreAuthorize("@ss.hasPermi('productApportionment:productApportionment:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProductApportionment productApportionment)
    {
        startPage();
        List<ProductApportionment> list = productApportionmentService.selectProductApportionmentList(productApportionment);
        return getDataTable(list);
    }

    /**
     * 导出产品分摊列表
     */
    @PreAuthorize("@ss.hasPermi('productApportionment:productApportionment:export')")
    @Log(title = "产品分摊", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProductApportionment productApportionment)
    {
        List<ProductApportionment> list = productApportionmentService.selectProductApportionmentList(productApportionment);
        ExcelUtil<ProductApportionment> util = new ExcelUtil<ProductApportionment>(ProductApportionment.class);
        return util.exportExcel(list, "productApportionment");
    }

    /**
     * 获取产品分摊详细信息
     */
    @PreAuthorize("@ss.hasPermi('productApportionment:productApportionment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(productApportionmentService.selectProductApportionmentById(id));
    }

    /**
     * 新增产品分摊
     */
    @PreAuthorize("@ss.hasPermi('productApportionment:productApportionment:add')")
    @Log(title = "产品分摊", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductApportionment productApportionment)
    {
        return toAjax(productApportionmentService.insertProductApportionment(productApportionment));
    }

    /**
     * 修改产品分摊
     */
    @PreAuthorize("@ss.hasPermi('productApportionment:productApportionment:edit')")
    @Log(title = "产品分摊", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductApportionment productApportionment)
    {
        return toAjax(productApportionmentService.updateProductApportionment(productApportionment));
    }

    /**
     * 删除产品分摊
     */
    @PreAuthorize("@ss.hasPermi('productApportionment:productApportionment:remove')")
    @Log(title = "产品分摊", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(productApportionmentService.deleteProductApportionmentByIds(ids));
    }
}
